const imgBaseUrl = 'http://p8i4pc54s.bkt.clouddn.com';
const defaultImage ='https://static.newyali.com/yaliapi/827/product/36c6b201805171541049535.png';
export const filterImg = (obj, key) => {
    let strRegex = "^((https|http)?://)";
    let re=new RegExp(strRegex);
    if (obj && obj[key]) {
         obj[key]=!re.test(obj[key])?imgBaseUrl + obj[key]:obj[key];
    } else if (obj && obj.get && obj.get(key)) {
        let url=!re.test(obj.get(key))?imgBaseUrl + obj.get(key):obj.get(key);
        return obj.set(key,url);
    }else if (obj && obj[key]==''){
       obj[key] = defaultImage;
    }
    return obj;
};
export default imgBaseUrl;
